import { Module } from '@nestjs/common';
import { APP_GUARD } from '@nestjs/core';
import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { UserModule } from './module/user/user.module';
import { WechatModule } from './module/wechat/wechat.module';
import { OssModule } from './module/oss/oss.module';
import { AuthGuard } from './guard/auth.guard';
import { OrderModule } from './module/order/order.module';
import { CouponModule } from './module/coupon/coupon.module';
import configuration from 'config/configuration';

@Module({
  imports: [
    TypeOrmModule.forRoot(configuration.mysql as TypeOrmModuleOptions),
    UserModule,
    WechatModule,
    OssModule,
    OrderModule,
    CouponModule,
  ],
  controllers: [AppController],
  providers: [
    AppService,
    {
      provide: APP_GUARD,
      useClass: AuthGuard,
    },
  ],
})
export class AppModule {}
